package com.henghai.zhenxuan.domain.request;

import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.LifecycleOwner;

import com.henghai.zhenxuan.data.api.AdoptListApi;
import com.henghai.zhenxuan.data.api.AdoptPetApi;
import com.henghai.zhenxuan.data.api.AdoptionOrderApi;
import com.henghai.zhenxuan.data.bean.AdoptListBean;
import com.henghai.zhenxuan.data.bean.AdoptionOrderBean;
import com.henghai.zhenxuan.data.bean.HttpBean;
import com.henghai.zhenxuan.data.repository.DataRepository;
import com.kunminx.architecture.data.response.DataResult;
import com.kunminx.architecture.domain.message.MutableResult;
import com.kunminx.architecture.domain.message.Result;
import com.kunminx.architecture.domain.request.Requester;

import org.jetbrains.annotations.NotNull;

public class AdoptListRequester extends Requester implements DefaultLifecycleObserver {
    private final MutableResult<DataResult<HttpBean<AdoptListBean>>> noticeResult = new MutableResult<>();
    private final MutableResult<DataResult<HttpBean<HttpBean>>> adoptResult = new MutableResult<>();
    private final MutableResult<DataResult<HttpBean<AdoptionOrderBean>>> adoptionOrderResult = new MutableResult<>();

    public Result<DataResult<HttpBean<AdoptListBean>>> getAdoptListTaskResult() {
        return noticeResult;
    }


    public Result<DataResult<HttpBean<AdoptionOrderBean>>> getAdoptionOrderResult() {
        return adoptionOrderResult;
    }

    public void requestAdoptList(LifecycleOwner lifecycleOwner, String pageNum, String pageSize) {
        DataRepository.getInstance().adoptList(lifecycleOwner, new AdoptListApi(), noticeResult::postValue);
    }


//    public Result<DataResult<HttpBean<HttpBean>>> getAdoptResult() {
//        return adoptResult;
//    }
//    public void adoptResult(LifecycleOwner lifecycleOwner, int petId) {
//        DataRepository.getInstance().adoptResult(lifecycleOwner, new AdoptPetApi(String.valueOf(petId)), adoptResult::postValue);
//    }
    public void adoptionOrderResult(LifecycleOwner lifecycleOwner, int petId, int adoptionQuantity) {
        DataRepository.getInstance().adoptionOrderResult(lifecycleOwner, new AdoptionOrderApi(String.valueOf(petId), String.valueOf(adoptionQuantity)), adoptionOrderResult::postValue);
    }


    public void cancelLogin() {

    }


    @Override
    public void onStop(@NonNull @NotNull LifecycleOwner owner) {
        cancelLogin();
    }

}
